﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FollowerElement
{
    public static Camera ScreenCamera{set;get;} = Camera.main;
    public Vector3 NodeYOffset{private set;get;}
    private RectTransform rect;


    public void DestroyRect()
    {
        if(rect)
            Object.Destroy(rect.gameObject);
    }

    public void SetRectPosFromWorldObj(Transform followerRoot,Vector3 screenPosOffset)
    {
        rect.position = ScreenCamera.WorldToScreenPoint(followerRoot.position);
        rect.position += screenPosOffset;
    }


    public FollowerElement(RectTransform rect,Vector3 yOffset)
    {
        this.rect = rect;
        this.NodeYOffset = yOffset;
    }
}